﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WordSmith_V1.Library.Model.EntityFrameWork;

namespace WordSmith_V1.Library.Security
{
    public class UserService 
    {
        public bool CheckUserCredentials(WordSmithContext DB, string email, string password)
        {
            bool success=false;
            var checkCredentialExist = DB.Credentials.Where(c => c.Email == email).Take(1).ToList().FirstOrDefault();
            if (checkCredentialExist != null)
            {
                success = Encryption.CheckHash(password,checkCredentialExist.EncryptedHash);
            }
            else
            {
                success = false;
            }
            return success;
        }

    }
}
